var title1=null;
$(document).ready(function () {
    $.ajax({
        type: "get",
        url: "/intermediate/getbackofficetree",
        async: true,
        success: function (res) {
            console.log(res.menulists)
            zTreeObj = $.fn.zTree.init($("#treeDemo"), {
                async: {
                    enable: true
                },
                edit: {
                    // enable: true,
                    drag: {
                        isMove: true, // 打开移动功能，鼠标左键点击后拖拽
                        prev: true,
                        autoOpenTime: 0
                    },
                    editNameSelectAll: true,
                    showRemoveBtn: true,
                    removeTitle: "删除节点",
                    renameTitle: "编辑节点名称",
                    showRenameBtn: true,
                },
                view: {
                    selectedMulti: false,
                    showIcon: true,// 显示图标
                    showLine: true,
                    // addHoverDom: addHoverDom
                    // removeHoverDom : removeHoverDom
                },
                data: {
                    simpleData: {
                        enable: true,
                        idKey: 'id',
                        pIdKey: 'pid',
                        rootPId: 0
                    },
                    key: {
                        name: "name"
                    }
                },
                check: {
                    enable: true,
                    chkStyle: "checkbox",
                    chkboxType: {"Y": "s", "N": "s"}
                },
                callback: {
                    onClick: clickTree
                }
            }, res.menulists); //初始化树
            zTreeObj.expandAll(true);   //true 节点全部展开、false节点收缩
        }
    });
});
function clickTree(event, treeId, treeNode) {
    console.log(treeNode.name);
    localStorage.setItem("treename",treeNode.name);
    var index = parent.layer.getFrameIndex(window.name);
    parent.layer.close(index);
}